package com.dinggao.bangda.interaction;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.dinggao.bangda.R;
import com.dinggao.bangda.view.CarownerActivity;
import com.dinggao.bangda.reserve.CarownerMore;
import com.dinggao.bangda.view.MainActivity;

/**
 * Created by Administrator on 2017/4/17.
 */

public class BeanFragment extends Fragment implements View.OnClickListener {

    private View view;

    private LinearLayout riding;
    private TextView moreCar;
    private TextView startSite;
    private TextView endSite;
    private TextView timeSite;
    private Button startRiding;
    private EditText remakeSite;
    private FragmentTransaction fragmentTransaction;
    private CarownerMore carownerMore;
    private MainActivity mainActivity;
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(R.layout.car_passenger_home, null);
            return view;
        }
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
    }

    private void initView(){
        carownerMore = new CarownerMore();
        riding = (LinearLayout) view.findViewById(R.id.car_passenger_home);
        moreCar = (TextView) view.findViewById(R.id.car_more);
        moreCar.setOnClickListener(this);
        startSite = (TextView) view.findViewById(R.id.start_site);
        startSite.setOnClickListener(this);
        endSite = (TextView) view.findViewById(R.id.end_site);
        endSite.setOnClickListener(this);
        timeSite = (TextView) view.findViewById(R.id.time_site);
        timeSite.setOnClickListener(this);
        startRiding = (Button) view.findViewById(R.id.start_riding);
        startRiding.setOnClickListener(this);
        remakeSite = (EditText) view.findViewById(R.id.remark_site);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.car_more:
                //出现更多司机列表
                Intent intent = new Intent(getActivity(), CarownerActivity.class);
                startActivity(intent);

//                Toast.makeText(getContext(), "BeanFragment", Toast.LENGTH_SHORT).show();
                break;
            case R.id.start_site:
                //弹出对话框，选择出发地点
                Toast.makeText(getContext(), "BeanFragment2", Toast.LENGTH_SHORT).show();
                break;
            case R.id.end_site:
                //弹出对话框，选择终点
                Toast.makeText(getContext(), "BeanFragment3", Toast.LENGTH_SHORT).show();
                break;
            case R.id.time_site:
                //弹出选择对话框
                Toast.makeText(getContext(), "BeanFragment4", Toast.LENGTH_SHORT).show();
                break;
            case R.id.start_riding:
                //获取输入的始点、终点、时间、备注
                Toast.makeText(getContext(), "BeanFragment5", Toast.LENGTH_SHORT).show();

                //获取备注
                remakeSite.getText().toString();
                break;
            default:
                break;
        }
    }
}
